package kyssion.leetcode.num101_150;

import kyssion.leetcode.util.TreeNode;

public class code111_二叉树的最小深度 {
    public int minDepth(TreeNode root) {
        if (root == null) {
            return 0;
        } else if (root.left == null && root.right == null) {
            return 1;
        } else {
            int left = minDepth(root.left);
            int right = minDepth(root.right);
            return Math.min(left == 0 ? Integer.MAX_VALUE : left, right == 0 ? Integer.MAX_VALUE : right) + 1;
        }
    }
}
